﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BuildPlannerLib
{
    // Base class for all 3 level upgrades
    public class LevelUpgrade
    {
        // String field for the name of the upgrade
        public string Name;

        // Integer properties for the base cost and production time duration
        private int mineralCost;
        private int gasCost;
        private int timeDuration;
        public int MineralCost
        {
            get { return mineralCost; }
            set { mineralCost = value; }
        }
        public int GasCost
        {
            get { return gasCost; }
            set { gasCost = value; }
        }
        public int TimeDuration
        {
            get { return timeDuration; }
            set { timeDuration = value; }
        }

        // Integer properties for the cost/time duration scaling per level
        private int mineralCostScaling;
        private int gasCostScaling;
        private int timeDurationScaling;
        public int MineralCostScaling
        {
            get { return mineralCostScaling; }
            set { mineralCostScaling = value; }
        }
        public int GasCostScaling
        {
            get { return gasCostScaling; }
            set { gasCostScaling = value; }
        }
        public int TimeDurationScaling
        {
            get { return timeDurationScaling; }
            set { timeDurationScaling = value; }
        }

        // Fields for the level of upgrade that is started and finished
        public int LevelStarted;
        public int LevelFinished;

        // String property for the structure from which the upgrade is produced
        private string producedFrom;
        public string ProducedFrom
        {
            get { return producedFrom; }
            set { producedFrom = value; }
        }

        // String array for the required structure for each level of the upgrade
        public string[] Requirement;

        // Constructor with mineral cost, gas cost, production time, scalers for each, and production building
        public LevelUpgrade(string name, int mineralCost, int mineralCostScaling, int gasCost, 
            int gasCostScaling, int timeDuration, int timeDurationScaling, string producedFrom)
        {
            Name = name;

            MineralCost = mineralCost;
            MineralCostScaling = mineralCostScaling;
            GasCost = gasCost;
            GasCostScaling = gasCostScaling;
            TimeDuration = timeDuration;
            TimeDurationScaling = timeDurationScaling;

            ProducedFrom = producedFrom;

            Requirement = new string[3] { null, null, null };
        }

        // Constructor with mineral cost, gas cost, production time, scalers for each, production building, and required building array
        public LevelUpgrade(string name, int mineralCost, int mineralCostScaling, int gasCost,
            int gasCostScaling, int timeDuration, int timeDurationScaling, string producedFrom,
            string[] requirement)
        {
            Name = name;

            MineralCost = mineralCost;
            MineralCostScaling = mineralCostScaling;
            GasCost = gasCost;
            GasCostScaling = gasCostScaling;
            TimeDuration = timeDuration;
            TimeDurationScaling = timeDurationScaling;

            ProducedFrom = producedFrom;

            Requirement = requirement;
        }

        // Resets the upgrade to 0
        public void Reset()
        {
            LevelStarted = 0;
            LevelFinished = 0;
        }
    }
}
